
/*
*Released on 28th June 2008.
*Any violations can be reported at paritosh@wikiocean.net
*What is treated as violations can be found at www.wikiocean.net/ppl1-voilations*
******************************************************************************
* The contents of this file are subject to POOL Public License 1.0 and later.
* POOL Public License is based on Affero GPL v3 and additional conditions.
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the Affero GPL v3 License at http://www.gnu.org/licenses/agpl.html
* You may obtain a copy of the POOL Public License 1.0 or later at www.wikiocean.net/license/ppl.html
* Software distributed under POOL Public License 1.0 is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Initial Developer of the Original Code is Paritosh Pungaliya (C) 2008. All Rights Reserved.
******************************************************************************
* Objective of the additional terms (license)
* 1) Is to extend the software freedom to freedom to work.
* 2) To ensure that knowledge is free from monopoly of agencies.
* 3) To avoid a situation where big corporate or investor can buy out free software groups and companies and then start milking the communities built around it.
* (this trend can be seen how the freedom is curtailed in companies that get Venture Capital funding.)
******************************************************************************
*/

package  query.query;

import java.util.Hashtable;
import java.util.Vector;

import logger.PoolLogger;
import dbmanager.GetIdName;
/**
 * <pre>When Report is System generated report then we need to generate run time condition.
 * We can generate  run time condition by using Key.
 * key is used as condition field in the condition.</pre> 
 * @author mahendra
 */
public class Key implements Queryinterface 
{

	String tablename;
	GetIdName gid;
	String[] buffer;
	String[] Querybuffer;
	String key="no$";
	int Querycount=1;
	String value="no$";
	String object;
	String Query;
	String Reportname;
	Hashtable<Object, Object> QueryMap  = new Hashtable<Object, Object>();
	String tid;
	PoolLogger pl;
	
	
	public void queryProcess(){
		
	}
	
	
	
	public Key() {
		// logger
		pl = (PoolLogger) PoolLogger.getLogger(this.getClass().getName());
	}
	
	/**
	 * getresult()  method set key  
	 */
		
	
	public void getResult()
	{
	}
	
	public String[] executeQuery(){return null;}

	public void initializeData() 
	{
		
	}
	/**
	 * set DBManager object
	 * @param db is DBManager object  
	 */
	public void initPool() 
	{
		gid = new GetIdName();
	}
	/**
	 * set key Object
	 * @param Object is key object
	 */
	public void setObject(String object) 
	{	
		this.object = gid.getItem(object);
		if(this.object.equals("no$"))
			this.object = object;
	}
	/**
	 * this method set Querybuffer to result of inner query   
	 * @param Querybuffer : String array  
	 *   
	 */
	public void setQuerybuffer(String[] Querybuffer) 
	{
		this.Querybuffer = Querybuffer;
	}
	/**
	 * this method set buffer1 valiable 
	 * @param buffer : String array  
	 *  
	 */
	public void setbuffer(String[] Querybuffer) 
	{
		this.buffer = Querybuffer;
	}
	/**
	 * settablename method set tablename 
	 * @param tablename : table name of query
	*/
	public void settablename(String tablename) 
	{
		this.tablename = tablename;
	}
	/**
	 * gettablename return tablename 
	 * @return tablename
	 */
	public String gettablename() 
	{
		return tablename;
	}
	/**
	 * getbuffer()
	 * @return buffer  
	 */
	public String[] getbuffer() 
	{
		return buffer;
	}
	/**
	 * getQuerybuffer()
	 * @return result of inner query
	 */
	public String[] getQuerybuffer()
	{
		return Querybuffer;
	}
	/**
	 * setkey()
	 * @param key of query
	 * 
	 */
	public void setKey(String key) 
	{
		//object = '\'' + object +'\'';  
		this.key = gid.getItem(object);
		if(this.key.toString().equals("no$"))
			this.key =object;
		this.key = this.key.replace("\'","");
	}

	public void setValue(String value) 
	{
		this.value = value;
	}

	public String getkey() 
	{
		return key;
	}


	public String getvalue() 
	{
		return value;
	}

	public Hashtable<Object, Object> getQueryMap() 
	{
		return QueryMap;
	}

	public void setQueryMap(Hashtable<Object, Object> QueryMap) 
	{
		this.QueryMap = QueryMap;
	}
	/**
	 * gettid() 
	 * @return tid
	 */
	public String gettid() 
	{
		return tid;
	}
	/**
	 * settid method takes following parameters :
	 * @param tid 
	 * this method set tid od condition class
	 */
	public void settid(String tid) 
	{
		this.tid =tid;	
	}
	/**
	 * when process is add then addreport is call  
	 */
	public void addReport() 
	{
		
	}

	/**
	 * when process is mod then updatereport is call  
	 */
	public void updateReport() 
	{
		
	}

	public String getReportname() 
	{
		return Reportname;
	}

	public void setReportName(String Reportname) 
	{
		this.Reportname  = Reportname;
	}

	public void settypeofreport(String typeofreport)
	{
		
	}

	public void setReportmap(Hashtable<Object, Object> ReportMap) {
	
		
	}

	public void setreporton(String reporton) {
	
		
	}

	public void setViewObject(String object, char ch) 
	{
	  value = object;	
	}

	public void setQuery(String Query)
	{
		this.Query = Query;
	}
	public String getQuery() 
	{
		return Query;
	}
	
	@SuppressWarnings("unchecked")
	public void setViewObject(Vector<Object> PropertyMap) 
	{
	try {
		this.key = ((Hashtable<Object, Object>)PropertyMap.get(0)).get("key").toString();
		key = gid.getItem(key);
		if(key.equals("no$"))
			this.key = ((Hashtable<Object, Object>)PropertyMap.get(0)).get("key").toString();
	} catch (Exception e) 
	{
		e.printStackTrace();
	}	
	}

	
	public int getcount() {
	
		return Querycount;
	}

	
	public void setCount(int count) {
	this.Querycount = count;
		
	}

	
	public void setMaxcount(int count) {
	
		
	}

	
	public void buildQuery() {
	
		
	}
	public void setConditionMap(Vector<Object> QueryMap)
	{
		
	}
	
	public void setProcess(String process) {
	
		
	}

}
